
import numpy as np

from datas import datas
X=[]
Y=[]
cityMark={"吕梁":1,"太原":2}
for item in datas:
    single=[]
    single.append(cityMark[item["city"]])
    single.append(item["area"])
    single.append(item["rooms"])
    single.append(item["school"])
    single.append(item["style"])
    X.append(single)
    Y.append(item["price"])

X=np.array(X)
Y=np.array(Y)
theta=np.linalg.pinv(X.T.dot(X).dot(X.T)).dot(X.T).dot(Y)
print(theta)